<?php $this->display("objects/breadcrumbs") ?>

<h2><?php _e($object['title']) ?></h2>
<p id="objdesc"><strong><?php _e($object['description']) ?></strong></p>

<?php if (count($usertags)): ?>
	<?php if ($usertag): ?>
		<p id="mytags" class="tagcloud"><strong><?php _e($usertag['name']) ?>'s tags:</strong> <?php $this->display("objects/tagcloud", array("terms" => $usertags, "user" => $usertag['name'])) ?></p>
	<?php else: ?>
		<p id="mytags" class="tagcloud"><strong>My tags:</strong> <?php $this->display("objects/tagcloud", array("terms" => $usertags, "user" => $member['name'])) ?></p>
	<?php endif; ?>
<?php endif; ?>

<?php if (count($globaltags)): ?>
	<p id="globaltags" class="tagcloud"><strong>Tags:</strong> <?php $this->display("objects/tagcloud", array("terms" => $globaltags)) ?></p>
<?php endif; ?>

<?php echo $object['content'] ?>

<?php if ($usertag): ?>
	<h4>User Tag: <?php _e($usertag['name']) ?> &raquo; <?php _e($showingtag) ?></h4>
	<p><em>There 
	<?php if ($tagobjectcount > 1): ?>
		are <?php _e($tagobjectcount) ?> discussions
	<?php elseif($tagobjectcount == 1): ?>
		is 1 discussion
	<?php else: ?>
		are no discussions
	<?php endif; ?> tagged <strong><?php _e($showingtag) ?></strong> by <a href="<?php echo Gene::makeLink(Gene::userId($usertag['name'])) ?>"><?php _e($usertag['name']) ?></a>. <a href="<?php echo Gene::makeLink($object) ?>">Show all discussions</a>.</em></p>
<?php elseif ($showingtag): ?>
	<h4>Tag: <?php _e($showingtag) ?></h4>
	<p><em>There 
	<?php if ($tagobjectcount > 1): ?>
		are <?php _e($tagobjectcount) ?> discussions
	<?php elseif($tagobjectcount == 1): ?>
		is 1 discussion
	<?php else: ?>
		are no discussions
	<?php endif; ?> tagged <strong><?php _e($showingtag) ?></strong>. <a href="<?php echo Gene::makeLink($object) ?>">Show all discussions</a>.</em></p>
<?php endif; ?>

<?php if ($mine): ?>
	<p><em>Showing all discussions started by <?php _e($member['name']) ?>.</em></p>
<?php endif; ?>

<?php if (count($reports)): ?>
	<p><strong>Moderation:</strong> There are <a href="<?php echo Gene::makeLink($object) ?>/edit/reports"><?php echo count($reports) ?> complaints</a> about comments which have not been resolved.</p>
<?php endif; ?>

<?php if (!$showingtag && count($forums)): ?>
	<table id="forumlist">
	<tr><th></th><th>Forum</th><th class="discussioncount">Discussions</th><th class="lastcomment">Latest Comment</th></tr>
	<?php foreach ($forums as $i): ?>
		<?php if (checkPermission($i, "view")): ?>
			<?php $this->display("objects/forum/listing", array("object" => $i)); ?>
		<?php endif; ?>
	<?php endforeach; ?>
	</table>
<?php endif; ?>

<div class="hfeed">
<?php if (count($childs)): ?>
	<table class="discussionlist">
	<tr><th></th><th class="discussion">Discussion</th><th class="comments">Comments</th><th class="lastcomment">Last Comment</th></tr>
	<?php if (count($pinned)): ?>
		<tr class="heading"><td></td><td>Sticky Discussions</td><td></td><td></td></tr>
		
		<?php foreach ($pinned as $i): ?>
			<?php $this->display("objects/discussion/listing", array("object" => $i, "sticky" => true)); ?>
		<?php endforeach; ?>
		
		<tr class="heading"><td></td><td>Discussions</td><td></td><td></td></tr>
	<?php endif; ?>
	
	<?php foreach ($normal as $i): ?>
		<?php $this->display("objects/discussion/listing", array("object" => $i)); ?>
	<?php endforeach; ?>
	</table>
<?php else: ?>
	<?php if ($showingtag || $mine): ?>
		<p><em>No discussions matched your criteria.</em></p>
	<?php else: ?>
		<p><em>There are no discussions in this forum. Why not start the first discussion?</em></p>
	<?php endif; ?>
<?php endif; ?>
</div>

<?php echo getPager(array(
	"object" => $object,
	"numpages" => $numpages,
	"currentpage" => $pagenum,
)) ?>

<?php if (checkPermission($object, "write")): ?>
	<?php $this->display("objects/discussion/create"); ?>
<?php endif; ?>